Repository navigation
test(mcpx): bind test sockets in a short socket dir, not t.TempDir (dezren39/nix#434) - #333
Merged
Merged
Conversation
) TestStopAllStopsDaemonFoundInDefaultDir rooted its XDG home in t.TempDir(), so under a nix sandbox build's long TMPDIR the daemon socket path exceeded Darwin's 104-byte sockaddr_un limit and bind failed with EINVAL before the stop logic ran. Add testsupport.SocketDir (a resolved scratch dir directly under /tmp that fails the test if a daemon.sock inside it would exceed the 100-byte ceiling), root the stop-all test's XDG home in it, and apply the same fix to sdnotify's TestReadyAndMainPIDReachTheSocket, which binds its notify socket on a t.TempDir path and fails identically under a long TMPDIR. Sibling audit: daemon socket tests are already safe (product socketPath hashed fallback / MkdirTemp directly under TMPDIR), verified by a full internal/daemon run under the same long TMPDIR.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Port of the fix for dezren39/darwin-nix#434 (origin issue for this cross-repo set; the identical mcpx copy lives in both repos)
Problem
TestStopAllStopsDaemonFoundInDefaultDirrooted its fake XDG home int.TempDir(), then bound a unix socket at<tmp>/mcpx/daemon.sock. Under a nix sandbox build the per-build TMPDIR is long and deeply nested, andt.TempDir()nests further (<tmp>/<TestName><rand>/001/...), pushing the socket path past Darwin's 104-bytesockaddr_unlimit —bind: invalid argumentbefore any stop logic runs. Reproduced on Linux (108-byte limit) with an artificially long TMPDIR: pre-fix the test fails atstopall_test.go:85with the issue's exact error.Solution
testsupport.SocketDir: a symlink-resolved scratch directory created directly under/tmp(the patterntestsupport.TempDir's out-of-home fallback and the daemon tests'isolate()already use), which fails the test if adaemon.sockinside it would exceed the 100-byte ceiling the product itself uses (daemon.maxSocketPath). NewTestSocketDirStaysShortUnderALongTmpDirpins it.stopall_test.go:customStateApproots the XDG home (the socket's host dir) inSocketDir.sdnotify'sTestReadyAndMainPIDReachTheSocketbinds its notify socket on at.TempDir()path and fails identically under the same long TMPDIR — fixed the same way. The daemon package's socket tests are already safe: the product'ssocketPathhashed fallback moves over-long sockets (verified:TestResolveReportsRunningOnlyWhenSomethingAcceptspasses under the long TMPDIR), and the server tests useos.MkdirTemp("", ...)directly under TMPDIR. A fullinternal/daemonrun under the long TMPDIR is green.Test-only change; no product code touched.
Verification
TestStopAllStopsDaemonFoundInDefaultDirFAIL (bind EINVAL),internal/sdnotifyFAIL the same way;internal/clisuite fails on only that one test.-count=5pass (the issue's acceptance command),internal/sdnotify+internal/testsupportpass.internal/cli(23.5s),internal/daemon(79.6s),internal/sdnotify,internal/testsupportsuites green;go vetclean on the touched packages; edited files gofmt-clean.The identical mcpx copy in developing-today/code gets the byte-identical change in a companion PR referencing this issue (one issue tracks the set, per the cross-repo rule).
Companion PR in dezren39/nix: dezren39/darwin-nix#444 (byte-identical change).
Need help on this PR? Tag
@codesmith-botwith what you need.Summary by CodeRabbit